#ifndef OUTPUT
#define OUTPUT

#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/Xutil.h>
#include <cstddef>
#include <cstdint>
#include "remotecontrol.hpp"
#include <vector>
namespace just
{
    struct event
    {
    public:
        int test;
    };
    // class j_gui
    // {
    // private:
    //     bool m_start = false;
    //     int m_rate = 1000;
    //     i_remoteControll *m_remote;
    //     int m_argc;
    //     char **m_argv;
    //     Display *my_display;
    //     Window root_window, my_window, game_window, tool_window, test_window;
    //     Visual *my_visual;
    //     int my_screen;
    //     XSetWindowAttributes my_attr;
    //     XSizeHints my_hints;
    //     int my_depth;
    //     GC gc;
    //     XGCValues gc_values;
    //     GC gc_string;
    //     XGCValues gc_string_values;
    //     display_info current_state;
    //     void display(display_info display_info);

    // public:
    //     j_gui(int argc, char** argv, i_remoteControll* remote);
    //     ~j_gui();
    //     int run();
    // };
    
    class j_applet 
    {
    private:
        bool m_is_init = false;
        point m_position;
        uint16_t m_width;
        uint16_t m_height;

        Display *m_display;
        Window m_root_window;
        void init(Window root_window, Display *display);
    
    public: 
        j_applet(point position, uint16_t width, uint16_t htight, void (*event_func)(event) = nullptr);
        ~j_applet();
        virtual void update() = 0;
        point get_position();
        void set_position(point position);
        Window get_window();
        uint16_t get_width();
        uint16_t get_height();
        void set_width(uint16_t width);
        void set_height(uint16_t height);
        Display get_display();
    };

    class j_window
    {
    private:
        int m_depth;
        Display *m_display;
        int m_screen;
        Window m_root_window;
        Window m_this_window;
        point m_position;
        uint16_t m_width;
        uint16_t m_height;
        std::string m_title;
        std::vector<j_applet*> m_applets;
        int m_applets_count;
        Visual *m_visual;
        XSetWindowAttributes m_attributes;
        void draw();
        
    public:
        j_window(point position, uint16_t width, uint16_t height, std::string title);
        ~j_window();
        void add(j_applet* applet);
        void close();
        int run();
    };

    class j_button: public j_applet
    {
    private:
        Window m_window;
        Display *m_display;
        std::string m_text;
        void draw();

    public:
        j_button(point position, uint16_t width, uint16_t height, std::string text, void (*event_func)(event));
        ~j_button();

        void update() override;
    };   
}

#endif
